# -*- coding: utf-8 -*-
from venv1.Page.otherInfoPage import otherinfoPage
from selenium.common.exceptions import NoSuchElementException
import time
from venv1.Public.xlsx_utils import XlsxUtils

class otherInfo():
    def __init__(self, driver):
        self.driver = driver
        self.otherInfo = otherinfoPage(self.driver)

    def otherinfo(self, list_data, filename, rownum):
        time.sleep(3)
        self.otherInfo.declare().click()
        time.sleep(1)
        if list_data[94] != "中国税收居民":
            self.otherInfo.birthContry().click()
            time.sleep(1)
            self.otherInfo.birthContryCon(list_data[95]).click()
            self.otherInfo.revenue().click()
            time.sleep(1)
            self.otherInfo.revenueDis().click()
        else:
            self.otherInfo.declarecon(list_data[94]).click()
        if list_data[29] == "本人":
            self.otherInfo.policyHeight().send_keys(list_data[92])
            self.otherInfo.policyWeight().send_keys(list_data[93])
        else:
            self.otherInfo.insurename(list_data[31]).click()
            time.sleep(1)
            self.otherInfo.insureHeight().send_keys(list_data[96])
            self.otherInfo.insureWeight().send_keys(list_data[97])
        self.otherInfo.Belonger().click()
        time.sleep(1)
        if list_data[29] == "本人":
            self.otherInfo.BelongerCon(list_data[0]).click()
        else:
            self.otherInfo.BelongerCon(list_data[31]).click()
        self.otherInfo.endDate().send_keys(list_data[100])
        self.otherInfo.submit().click()
        time.sleep(2)
        self.otherInfo.confirm().click()
        xlutil = XlsxUtils()
        time.sleep(2)
        xlutil.set_sheet_value(filename=filename, sheetname="Sheet1", row=rownum + 1, col=102, value="成功")
        time.sleep(3)

